# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-lambda-term
_pkgname=lambda-term
pkgver=3.2.0
pkgrel=3
pkgdesc="Terminal manipulation library for OCaml"
url="https://github.com/ocaml-community/lambda-term"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-3-Clause"
depends="
	ocaml-runtime
	ocaml-camomile
	ocaml-lwt
	ocaml-lwt_log
	ocaml-lwt_react
	ocaml-mew_vi
	ocaml-zed
	"
# ocaml-lwt_react-dev is provided by ocaml-lwt-dev
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-camomile-dev
	ocaml-lwt-dev
	ocaml-lwt_log-dev
	ocaml-mew_vi-dev
	ocaml-zed-dev
	"
makedepends="$depends_dev dune ocaml"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-community/lambda-term/releases/download/$pkgver/lambda-term-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install --destdir="$pkgdir"
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
46cd46f47c9f34c0a5e096b96e6eec59667b645bf5201140e498e6d4eb9baba8204a2b30b73c4b2f8140e5cf1972a56e3aa485b27bc5ace25b2c368f713ad7c4  ocaml-lambda-term-3.2.0.tar.gz
"
